package 力扣算法练习.main1.newPart1;

public class day6 {
    //https://www.nowcoder.com/questionTerminal/e1bb714eb9924188a0d5a6df2216a3d1
    public boolean checkWon(int[][] board) {
        // write code here
        //检查行
        int count = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                count += board[i][j];
            }
            if (count == 3) {
                return true;
            }
            count = 0;
        }
        //检查列
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                count += board[j][i];
            }
            if (count == 3) {
                return true;
            }
            count = 0;
        }
        //检查对角线
        count += board[0][0] + board[1][1] + board[2][2];
        if (count == 3) {
            return true;
        }
        count = board[0][2] + board[1][1] + board[2][0];
        if (count == 3) {
            return true;
        }
        return false;
    }
}
